<include file="Public:top" /> 
<script src="__PUBLIC__/Static/Uploadify/jquery.uploadify-3.1.min.js"></script>
<link href="__PUBLIC__/Static/Uploadify/uploadify.css" rel="stylesheet">
<style>
.imagelist{}
.imagelist li{
    background: none repeat scroll 0 0 #F0F0F0;
    border: 1px solid #E0E0E0;
    display: inline;
    float: left;
	margin-right:10px;
	margin-top:5px;
    padding: 11px;
    width: 200px;
	height:250px;
	overflow:hidden;
	position: relative;
	
}
.imagelist li em{
    color: #999999;
    display: block;
    line-height: 18px;
    padding: 8px 0px;
}

.imagelist li span.txt {
    color: #FFFFFF;
	display:none;
    line-height:25px;
	height:25px;
    width: 200px;
	text-align:right;
	position:absolute;
	top:0px;
	right:0px;
}
</style>
<script>
	$(function(){
		$("#image_result").sortable();
		$('.imagelist li').live({
		   mouseenter:
		   function()
		   {
			  $(this).find('.txt').css('display','block');
		   },
		   mouseleave:
		   function()
		   {
			  $(this).find('.txt').css('display','none');
		   }
		});
		
		$("#upload").uploadify({
			height        : 30,
			swf           : '__PUBLIC__/Static/Uploadify/uploadify.swf',
			uploader      : '{:U("Uploadify/upload")}',
			width         : 120,
			buttonText	  : 'Upload',
			auto		  : true,
			removeCompleted: false,
			onUploadSuccess: function(file, data, response) {
				$('#progress').hide();
				var result = $.parseJSON(data);
				//错误处理。。。
				if(result.status == 0){
					alert(result.message);
					return false;
				}
				//上传成功
				var id = Math.random().toString();
				id = id.replace('.','_'); //生成唯一标示
				var html = '<li class="imageitem" id="'+id+'" style="padding:10px;background:#FFF">';
					html+= '<input type="hidden" name="file[]" value="'+result.file_name+'">'; //隐藏域，是为了把图片地址入库。。
					html+=  '<span class="txt">';
					html+=  '<a title="del" href=javascript:remove("'+result.file_name+'","'+id+'");><img src="__PUBLIC__/Static/Uploadify/remove.png" /></a>';
					html+=  '</span>';
					html+= '<img height="200" width="200" src="'+result.file+'" />';
					html+=  '<em><textarea style=" height:20px;width:155px;" name="htmlcontent[]">'+file.name+'</textarea> </em>';
					html+=  '</li>';
				$('#image_result').append(html);
			},
			onUploadStart: function(){
				$('#progress').text('waiting...');  //用户等待提示。
			},
			onInit: function (){  
				$("#upload-queue").hide(); //隐藏上传队列                
			}		
		});
	})
	function remove(file,id){
		$.getJSON('{:U("removeImg")}',{file:file},function(data){$('#'+id).remove()})
	}
	function removePic(id){
		$.getJSON('{:U("removePic")}',{id:id},function(data){$('#b_'+id).remove()})
	}
</script> 
<script>
    var imgPlus = new Image();
    imgPlus.src = "__PUBLIC__/images/menu_plus.gif";
    
    function rowClicked(obj)
    {
      // 当前图像
      img = obj;
      // 取得上二级tr>td>img对象
      obj = obj.parentNode.parentNode;
      // 整个分类列表表格
      var tbl = document.getElementById("list");
      // 当前分类级别
      var lvl = parseInt(obj.className);
      // 是否找到元素
      var fnd = false;
      var sub_display = img.src.indexOf('menu_minus.gif') > 0 ? 'none' : (Browser.isIE) ? 'block' : 'table-row' ;
      // 遍历所有的分类
      for (i = 0; i < tbl.rows.length; i++)
      {
          var row = tbl.rows[i];
          if (row == obj)
          {
              // 找到当前行
              fnd = true;
              //document.getElementById('result').innerHTML += 'Find row at ' + i +"<br/>";
          }
          else
          {
              if (fnd == true)
              {
                  var cur = parseInt(row.className);
                  var icon = 'icon_' + row.id;
                  if (cur > lvl)
                  {
                      row.style.display = sub_display;
                      if (sub_display != 'none')
                      {
                          var iconimg = document.getElementById(icon);
                          iconimg.src = iconimg.src.replace('plus.gif', 'minus.gif');
                      }
                  }
                  else
                  {
                      fnd = false;
                      break;
                  }
              }
          }
      }
    
      for (i = 0; i < obj.cells[0].childNodes.length; i++)
      {
          var imgObj = obj.cells[0].childNodes[i];
          if (imgObj.tagName == "IMG" && imgObj.src != '__PUBLIC__/images/menu_arrow.gif')
          {
              imgObj.src = (imgObj.src == imgPlus.src) ? '__PUBLIC__/images/menu_minus.gif' : imgPlus.src;
          }
      }
    }
   
</script>      
	</head>
  
	<body>
    
    <div id="body-wrapper" > <!-- Wrapper for the radial gradient background -->		

        <!--left start-->
		
        <include file="Public:left" /> 
        <!--left end-->
        
        
        <!-- End #sidebar -->			
		<div id="main-content"> <!-- Main Content Section with everything -->
        <div  id="header_logo">{:C("SITE_INFO.name")}</div>	 		
			
			<!-- Page Head -->
			<div style="float:left; width:380px;">
			  <h2>Add/Edit Products</h2></div>

            
			<div class="clear"></div> <!-- End .clear -->
			         
                <!-- Insert -->
                <div class="content-box">				
                    <div class="content-box-header">                    
                        <ul class="content-box-tabs">						
                            <li><a href="#tab1" class="default-tab current" style="text-transform:capitalize">General</a></li>
	                        <li><a href="#tab2" class="">Category</a></li>   
                            <li><a href="#tab3" class="">Data</a></li>    
                            <li><a href="#tab4" class="">Images</a></li>                  		
                        </ul>
                        <span class="insert" style=" float:right; line-height:40px; font-size:14px; font-weight:bold;"><a href="{:U('index')}">List </a>&nbsp; &nbsp; </span> 		                            	
                      <div class="clear"></div>					
                    </div>
                   
                    <form action="{:U($action)}" method="POST" name="editForm" enctype="multipart/form-data"> 
                    <div class="content-box-content">		
                    	
                        <div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->	
                        
                        <div id="sub_tabs">                               
                               	  <ul>
                                    <volist name="lang" id="vo" key="k" >                                    
                                    	<li><a href="#tabs2-{$vo.value}"><img src="__PUBLIC__/images/{$vo.value}_icon.gif"> {$vo.txt}</a></li>
                                    </volist>   
                                 </ul>
                           
                               
                                <volist name="langList" id="vo" key="k" >         
                                	<div class="tabs" id="tabs2-{$vo}">                                    
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="editContent">
                                      <tr>
                                        <td class="fieldText">Title:</td><td><input class="text-input small-input" value="{$titleArr[$k]}" style="width:590px!important"  type="text" id="products_name_{$k}" name="products_name_{$k}" /></td>
                                      </tr>
                                      <tr>  
                                        <td  class="fieldText" style="vertical-align:top;">Description:</td><td> <textarea style="height:300px;width:590px!important" class="page_description HTMLeditor" name="products_description_{$k}">{$descArr[$k]}</textarea></td>
                                      </tr>
                                    </table>    
                                    </div>                                         
                                 </volist>   
                              </div>
                        
                        
                             <!--<p>
                             <label>Products Name:</label>                                
                               <volist name="langList" id="vo" key="k" >
                              	<p>
                                	<img src="__PUBLIC__/images/{$vo}_icon.gif"> 
                                    <input class="text-input small-input" value="{$titleArr[$k]}" style="width:590px!important"  type="text" id="products_name_{$k}" name="products_name_{$k}" /> 
                                </p>
                              </volist>                     
                            </p>
                             <p>
                              <label>Products Description:</label> 
                               <volist name="langList" id="vo" key="k" >
                              	<div><div style="float:left"><img src="__PUBLIC__/images/{$vo}_icon.gif">&nbsp;</div><div style="float:left"> 
                                <textarea style="height:300px;width:590px!important" class="page_description" name="products_description_{$k}">{$descArr[$k]}</textarea></div></div><div style="clear:both"><br /></div>
                              </volist>                             
                            </p>-->
                             
       	
                        </div> <!-- End #tab1 --> 
                        
                        <div class="tab-content" id="tab2" style="display: none;"> <!-- This is the target div. id must match the href of this div's tab -->	
                                <table id="list">
                                <foreach name="cate" item="vo">
                                    <tr align="center" id="{$vo.parent_id}_{$vo.categories_id}" class="{$vo.level}">
                                          <td align="left" class="first-cell" >
                                            <img width="9" height="9" border="0" onClick="rowClicked(this)" style="margin-left:{$vo['level']*10}px; cursor:pointer;" id="icon_{$vo.parent_id}_{$vo.categories_id}" src="__PUBLIC__/images/menu_minus.gif">&nbsp;
                                            <span><strong><input name="categories_id[]" type="checkbox"  value="{$vo.categories_id}" <foreach name="categories" item="c"><if condition="$c['categories_id'] eq $vo['categories_id']">checked="checked"</if> </foreach>/>&nbsp;&nbsp;&nbsp;{$vo.categories_description.0.categories_name}</strong></span>
                                          </td>
                                    </tr>
                                </foreach>
                                </table>           
                            	
                        </div>   <!-- End #tab2 --> 
                        <div class="tab-content" id="tab3" style="display: none;"> <!-- This is the target div. id must match the href of this div's tab -->	
                            <p>
                              <label>Status:<input type="checkbox" style="vertical-align:middle" name="products_status"  value="1" <if condition="$infoList['products_status'] eq 1">checked="checked"</if>/></label>
                                                                                               
                            </p>
                             <p>
                              <label>Products Model:</label> <input class="text-input small-input" type="text" name="products_model" value="{$infoList.products_model}" />                                           
                            </p> 
                             <p>
                              <label>Products Price:</label> <input class="text-input small-input" type="text" name="products_price" value="{$infoList.products_price}"/>                                            
                            </p> 
                             <p>
                              <label>Products Weight:</label> <input class="text-input small-input" type="text" name="products_weight" value="{$infoList.products_weight}"/>                                         
                            </p>  
                             <p>
                              <label>Products Quantity:</label> <input class="text-input small-input" type="text" name="products_quantity" value="{$infoList.products_quantity}"/>                                          
                            </p>   
                            <p>
                              <label>Sort Order:</label> <input class="text-input small-input" type="text" name="sort_order" value="{$infoList.sort_order}"/>                                            
                            </p>
                         </div>
                          <div class="tab-content" id="tab4" style="display: none;"> <!-- This is the target div. id must match the href of this div's tab -->	
                            <p>
                              <label>Main Image:<input type="file" name="products_image">  {$imageShow}  </label>                                 
                            </p>  
                            <p>
                              <label>Images:<span><a style="float:right" id="upload"></a></span><div id="progress"></div>
                              <ul class="imagelist" id="image_result">
                              <foreach name="BigImg" item="v">
                              	<li class="imageitem" id="b_{$v['id']}" style="padding:10px;background:#FFF">
                                	<span class="txt">
                                    <a title="Delete" href=javascript:removePic("{$v['id']}");><img src="__PUBLIC__/Static/Uploadify/remove.png" /></a>
                                    </span>
                                    <a class="fancyBox"  href="__PUBLIC__/images/products/{$v['image']}"><img height="200" width="200" src="__PUBLIC__/images/products/{$v['image']}" /></a>
                                    <em><textarea name="imgcontent[{$v['id']}]" style="height:20px;width:200px;">{$v['htmlcontent']}</textarea><input type="hidden" name="img_sort[]" value="{$v.id}"/></em>
                               </li>
                              </foreach>
                              </ul>
                              <div class="clear"></div></label>                       
                            </p>  
                            	
                        </div>   <!-- End #tab3 --> 
                              	
                    </div>  
                          <div style="padding:0 0 20px 20px">  
                            <input  name="products_id" value="{$infoList.products_id}" type="hidden"/>
                            <input class="button" style="text-transform:capitalize" type="button" name="BtnSave" onClick="document.editForm.submit()"  value="{$actionName}" />&nbsp;&nbsp;
                            <input class="button" type="button" name="back" onClick="window.location.href='{:U('index')}'"  value="Back" />   
                          </div>  
                    </form>     
                	
                </div> 
                <!--End Insert -->
        
			
			
			<div class="clear"></div>
			
			
			<!-- Start Notifications -->
			
			

			
			<!-- End Notifications -->
			
            <div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
						&#169; Copyright 2013
				</small>
			</div>
			
			
			
			<!-- End #footer -->
			
		</div> <!-- End #main-content -->
		
	</div>
	
	<script>
    	$(function(){
					$('.content-box-content ul.tab-content').hide(); // 先隐藏DIV
					$('ul.content-box-tabs li a.default-tab').addClass('current'); // 给默认的选项卡加样式
					$('.content-box-content ul.default-tab').show(); //
					 
					$('ul.content-box-tabs li a').click( //
					function() {
						$(this).parent().siblings().find("a").removeClass('current'); //
						$(this).addClass('current'); //
						var currentTab = $(this).attr('href'); //
						$(currentTab).siblings().hide(); //
						$(currentTab).show(); //
						return false;
					}
			);
			 $( "#sub_tabs" ).tabs();  
		});
    
     function delImages()
		{
			  $("#image").html('');
			  $("input[name=del_iamge]").val("true");			  
		} 
    
    </script>
	
	</body>
<!-- Download From www.exet.tk-->
</html>